<?php
apf_require_class('Solr_Bll_BaseBiz');
class Solr_Bll_ReportBiz extends Solr_Bll_BaseBiz {

    private static $instance;

    public static function &get_instance() {
        if(!self::$instance){
           	self::$instance = new self();
        }
        return self::$instance;
    }

    public function logic_update_report($params){

        @extract($params);
        if(!$application_id||!$datei)return false;
        $report_dao=$this->get_report_dao();
        $report_info=$report_dao->get_report_info($application_id,$datei);

        $attr['doc_number']=($doc_number)?$doc_number:0;
        $attr['doc_number_time']=($doc_number_time)?$doc_number_time:0;
        $attr['count_min']=($count_min)?$count_min:0;
        $attr['slow_min']=($slow_min)?$slow_min:0;
        $attr['max_count_min']=($max_count_min)?$max_count_min:0;
        if($report_info){
            $res=$report_dao->update_report($attr,$application_id,$datei);
        }else{
            $attr['application_id']=$application_id;
            $attr['hostname_id']=$hostname_id;
            $attr['webapp_id']=$webapp_id;
            $attr['datei']=$datei;
            $res=$report_dao->insert_report($attr);
        }
        return $res;
    }

    public function get_reports_list($params,$page,$limit=20){
        $page=max(1,intval($page));
        $report_dao=$this->get_report_dao();
        return $report_dao->get_reports_list($params,$page,$limit);
    }

    public function get_reports_count($params){
        $report_dao=$this->get_report_dao();
        return $report_dao->get_reports_count($params);
    }
}